Antes de pasar por la molestia de la depuración, utilice el Marco de pruebas para comprobar si las pruebas estándar funcionan correctamente. Si no se ejecutan por completo, es posible que haya una instalación defectuosa.
La depuración de FreeCAD está respaldada por algunos mecanismos internos. La versión de línea de comandos de FreeCAD proporciona algunas opciones para soporte de depuración.
Estas son las opciones reconocidas actualmente en FreeCAD 0.19:
Opciones genéricas:
-v [ --version ] Imprime la cadena de versión -h [ --help ] Imprime el mensaje de ayuda -c [ --console ] Comienza en modo consola --response-file arg También se puede especificar con '@nombre' --dump-config Configuración de volcados --get-config arg Imprime el valor de la clave de configuración solicitada
Configuración:
-l [ --write-log ] Escribe un archivo de registro en: $HOME/.local/share/FreeCAD/FreeCAD.log (Linux) $HOME/Library/Application\ Support/FreeCAD/FreeCAD.log (macOS) %APPDATA%\FreeCAD\FreeCAD.log --log-file arg A diferencia de --write-log, esto permite iniciar sesión en un archivo arbitrario -u [ --user-cfg ] arg Archivo de configuración de usuario para cargar/guardar configuraciones de usuario -s [ --system-cfg ] arg Archivo de configuración del sistema para cargar/guardar la configuración del sistema -t [ --run-test ] arg Caso de prueba - o 0 para todos -M [ --module-path ] arg Rutas de módulos adicionales -P [ --python-path ] arg Rutas adicionales de Python --single-instance Permite ejecutar una única instancia de la aplicación
If you are running a version of FreeCAD from the bleeding edge of the development curve, it may "crash". You can help solve such problems by providing the developers with a "backtrace". To do this, you need to be running a "debug build" of the software. "Debug build" is a parameter that is set at compile time, so you'll either need to compile FreeCAD yourself, or obtain a pre-compiled "debug" version.
Depuración de Linux →
Requisitos previos:
Pasos: Ingrese lo siguiente en la ventana de su terminal:
Encuentre el binario FreeCAD en su sistema:
$ whereis freecad
freecad: /usr/local/freecad <--- for example
$ cd /usr/local/freecad/bin
$ gdb FreeCAD
GNUdebugger generará información de inicialización. El (gdb) muestra que GNUDebugger se está ejecutando en la terminal, ahora ingrese:
(gdb) handle SIG33 noprint nostop
(gdb) run
FreeCAD ahora se iniciará. Realice los pasos que hacen que FreeCAD se bloquee o se congele, luego ingrese en la ventana de terminal:
(gdb) bt
Esto generará una lista larga de exactamente lo que estaba haciendo el programa cuando falló o se congeló. Incluya esto con su informe de problemas.
(gdb) bt full
Imprima también los valores de las variables locales. Esto se puede combinar con un número para limitar la cantidad de fotogramas mostrados.
Depuración de macOS →
Requisitos previos:
Steps: Enter the following in your terminal window:
$ cd FreeCAD/bin
$ lldb FreeCAD
LLDB will output some initializing information. The (lldb) shows the debugger is running in the terminal, now input:
(lldb) run
FreeCAD will now start up. Perform the steps that cause FreeCAD to crash or freeze, then enter in the terminal window:
(lldb) bt
This will generate a lengthy listing of exactly what the program was doing when it crashed or froze. Include this with your problem report.
(Applicable to Linux and macOS)
Sometimes it's helpful to understand what libraries FreeCAD is loading, specifically if there are multiple libraries being loaded of the same name but different versions (version collision). In order to see which libraries are loaded by FreeCAD when it crashes you should open a terminal and run it in the debugger. In a second terminal window, find out the process id of FreeCAD:
ps -A | grep FreeCAD
Use the returned id and pass it to lsof
:
lsof -p process_id
This prints a long list of loaded resources. So for example, if trying to ascertain if more than one Coin3d library versions is loaded, scroll through the list or search directly for Coin in the output:
lsof -p process_id | grep Coin
For a more modern approach to debugging Python, see these posts:
winpdb Debugging →
Here is an example of using Winpdb inside FreeCAD:
We need the Python debugger: Winpdb. If you do not have it installed, on Ubuntu/Debian install it with:
sudo apt-get install winpdb
Now lets setup the debugger.
Now we will run a test Python script in FreeCAD step by step.
import rpdb2
rpdb2.start_embedded_debugger("test")
import FreeCAD
import Part
import Draft
print "hello"
print "hello"
import Draft
points=[FreeCAD.Vector(-3.0,-1.0,0.0),FreeCAD.Vector(-2.0,0.0,0.0)]
Draft.makeWire(points,closed=False,face=False,support=None)
VS Code Debugging →
Prerequisites:
# In a cmd window that has a path to you local Python 3:
pip install ptvsd
# Then if your Python is installed in C:\Users\<userid>\AppData\Local\Programs\Python\Python37
# and your FreeCAD is installed in C:\freecad\bin
xcopy "C:\Users\<userid>\AppData\Local\Programs\Python\Python37\Lib\site-packages\ptvsd" "C:\freecad\bin\Lib\site-packages\ptvsd"
Visual Studio Code documentation for remote debugging
Steps:
import ptvsd
print("Waiting for debugger attach")
# 5678 is the default attach port in the VS Code debug configurations
ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True)
ptvsd.wait_for_attach()
"configurations": [ { "name": "Python: Attacher", "type": "python", "request": "attach", "port": 5678, "host": "localhost", "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "." } ] },
from sys import path
sys.path.append('/path/to/site-packages')
Where the path is to the directory where ptvsd was installed.
In the Mac package it is /Applications/FreeCAD.App/Contents/Resources/bin/python.
You can locate it on your system by typing
import sys
print(sys.executable)
into FreeCAD's Python console.
LiClipse Debugging →
> ./your location/FreeCAD_xxx.AppImage --appimage-extract
> cd squashfs-root/
squashfs-root> ./usr/bin/freecadcmd
your loc/squashfs-root/usr/bin/python
.pydevd.py
in your liclipse installation.
your location/liclipse/plugins/org.python.pydev.xx/pysrc
.import sys; sys.path.append("path ending with /pysrc")
import pydevd; pydevd.settrace()
squashfs-root> ./usr/bin/freecad
pydevd.settrace()
trigger) from within freecad, as you would normally do.See the main article about Pyzo.
For developers needing to dig deeper in to the OpenCasCade kernel, user @abdullah has created a thread orientation discussing how to do so.